#ifndef _BDESYN_H_
#define _BDESYN_H_

class Bdesyn
{
	private:
	SDL_Surface* sprite;
	
	int off[2];
	int cord[2];
	
	int health;
	int memory;
	int direction;
	public:
	//Bdesyn(std::string,int,int,int,int);
    	Bdesyn(SDL_Surface*,int,int,int,int);
	void drawSprite(SDL_Surface*);
	int getCord(int);
	void setCord(int,int);
	SDL_Surface* getArray(int);
	void move(Handler);
	void setDirection(int);
	int getDirection();
};

/*Bdesyn::Bdesyn(std::string file, int x, int y, int sx=0, int sy=0)
{
	sprite[DIR_R]=loadImage(file+"_R.png");
	sprite[DIR_U]=loadImage(file+"_U.png");
	sprite[DIR_L]=loadImage(file+"_L.png");
	sprite[DIR_D]=loadImage(file+"_D.png");
	off[0]=x;
	off[1]=y;
	cord[0]=sx;
	cord[1]=sy;
}*/

Bdesyn::Bdesyn(SDL_Surface* spr, int x, int y, int sx=0, int sy=0)
{
	sprite=spr;
	off[0]=x;
	off[1]=y;
	cord[0]=sx;
	cord[1]=sy;
}

void Bdesyn::drawSprite(SDL_Surface* dest)
{
	int bx, by;
	bx=off[0]+(34*cord[0]);
	by=off[1]+(20*cord[1]);
	SDL_Surface* blt;
	cout<<"after?"<<endl;
	blt=getArray(getDirection());
	cout<<"or blit?"<<endl;
	blit(bx,by,blt,dest);
}

int Bdesyn::getCord(int axis)
{
	return cord[axis];
}

void Bdesyn::setCord(int axis, int value)
{
	cord[axis]=value;
}

SDL_Surface* Bdesyn::getArray(int dir)
{
	return sprite/*[dir]*/;
}

void Bdesyn::move(Handler ev)
{
   if(ev.getKeyPressed(SDLK_UP))
   {
       if(getCord(1)!=0)
       {
           setCord(1,getCord(1)-1);
           setDirection(DIR_U); 
       }
   }
   if(ev.getKeyPressed(SDLK_DOWN))
   {
       if(getCord(1)!=5)
       {
       	 setCord(1,getCord(1)+1);
           setDirection(DIR_D);
       }
   }
   if(ev.getKeyPressed(SDLK_LEFT))
   {
       if(getCord(0)!=0)
       {
       	 setCord(0,getCord(0)-1);
           setDirection(DIR_L);
       }
   }
   if(ev.getKeyPressed(SDLK_RIGHT))
   {
       if(getCord(0)!=8)
       {
       	 setCord(0,getCord(0)+1);
           setDirection(DIR_R);
       }
   }
}

void Bdesyn::setDirection(int _direction)
{
   direction=_direction;
}

int Bdesyn::getDirection()
{
   return direction;
}

#endif

